package com.ht.service.impl;

import com.ht.data.Result;
import com.ht.domain.po.TbPopularization;
import com.ht.mapper.PopularizationMapper;
import com.ht.service.PopularizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 科普号service
 */
@Service
public class PopularizationServiceImpl implements PopularizationService {

    @Autowired
    private PopularizationMapper popularizationMapper;

    /**
     * 根据科普号id修改科普号审核状态
     * @param popularizationId 科普号id
     * @param popularizationStatus 科普号状态
     * @return
     */
    @Override
    public Result updatePopularizationStatusByPopularizationId(Long popularizationId, Integer popularizationStatus) {
        TbPopularization tbPopularization = popularizationMapper.selectById(popularizationId);
        if (tbPopularization.getStatus() == popularizationStatus){
            return Result.OK();
        }
        tbPopularization.setStatus(popularizationStatus);
        int i = popularizationMapper.updateById(tbPopularization);
        if (i <= 0){
            return Result.ERROR();
        }
        return Result.OK();
    }
}
